package org.darkforest.controller;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import org.darkforest.common.services.AdvSerivce;
import org.darkforest.dao.mapper.AdvMapper;
import org.darkforest.model.Adv;
import org.darkforest.model.AdvBean;
import org.darkforest.model.RestEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by pc on 2017/11/27.
 */
@RestController
@RequestMapping(value = "adv")
@Api(value = "adv", description = "广告",produces= MediaType.APPLICATION_JSON_VALUE)
public class AdvController {
    @Autowired
    private AdvSerivce advSerivce;
    @RequestMapping(value = "list",method = RequestMethod.GET)
    @ApiOperation(value = "列表", httpMethod = "GET",produces= MediaType.APPLICATION_JSON_VALUE)
    public RestEntity list(@RequestParam(required = true)Integer apId){
        try{
            List<Adv> sendAdvs = advSerivce.getRedisAdvList(apId+"");
            return RestEntity.success(sendAdvs);
        }catch (Exception e){
            return RestEntity.failed();
        }
    }

}
